﻿using Common.Library.Db;
using Common.Library.StringExt.Randoms;
using CreateData.Entitys;
using CreateData.RandomHelp;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CreateData
{
    public class Create
    {
        #region 创建用户数据
        public void CreateUserInfo()
        {
            List<UserInfoEntity> userInfoList = new List<UserInfoEntity>();
            for (int j = 0; j < 100; j++)
            {
                for (int i = 0; i < 100000; i++)
                {
                    userInfoList.Add(new UserInfoEntity()
                    {
                        IdCrde = IDCardNumber.Radom(),
                        Name = RandomName.getRandomName(),
                        Phone = RandomMoble.GetMoble(),
                        Age = RandomExt.GetNumber(11, 111),
                        Gender = RandomExt.GetNumber(0, 2),
                        Address = RandomAddr.Random(),
                    });
                }
                IAppDBContext db = AppDBContextFactory.GetAppDBContext();
                DataTable dt = DataTableConvert.ToDataTable(userInfoList);
                string connStr = ConfigurationManager.ConnectionStrings["Conn"].ToString();
                string dataTableName = "UserInfo";
                db.BulkInsert(connStr, dataTableName, dt);
                userInfoList = new List<UserInfoEntity>();
            }
        }
        #endregion

        public void CreateJobRecord()
        {
            List<JobRecordEntity> jobRecordList = new List<JobRecordEntity>();
            for (int j = 0; j < 100; j++)
            {
                for (int i = 0; i < 100000; i++)
                {
                    jobRecordList.Add(new JobRecordEntity()
                    {
                        CreateTime = RandomTime.GetRandomTime(),
                        Position = 职位.Get职位(),
                        Salary = RandomExt.GetDecimal(1, 10000),
                        UserInfoId = RandomExt.GetNumber(1, 1499496)
                    });
                }
                IAppDBContext db = AppDBContextFactory.GetAppDBContext();
                DataTable dt = DataTableConvert.ToDataTable(jobRecordList);
                string connStr = ConfigurationManager.ConnectionStrings["Conn"].ToString();
                string dataTableName = "JobRecord";
                db.BulkInsert(connStr, dataTableName, dt);
                jobRecordList = new List<JobRecordEntity>();
            }
        }


    }
}
